#!/usr/bin/perl -wT
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
# 
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are Copyright (C) 1998
# Netscape Communications Corporation. All Rights Reserved.
# 
# Contributor(s): TomWij <TomWij@live.com>

##############################################################################
#
# addStatistic.cgi
# -----------------
# Add a suggestion to the MySQL table 'suggestions'.
#
##############################################################################

do '..\helpers\query.cgi';
$user = $FORM{user};
$algo = $FORM{suggested};
$choice = $FORM{choice};

use DBI;
use DBD::mysql;
use CGI;
$query = new CGI;

print "Content-type: text/html\n\n";

# Get more information about the user and his choice.
$cookie = $query->cookie('Bugzilla_logincookie');

# Add a suggestion to the MySQL table 'suggestions'.
do '..\..\..\..\localconfig';
$driver = DBI->install_driver("mysql"); 
$connect = $driver->connect("DBI:mysql:database=$db_name;host=$db_host", $db_user, $db_pass, {}) or print "<b>MySQL: Connection failed.</b>";

$query = "INSERT INTO suggestions (bid, pid, cid, user, user_severity, algo_severity, choice_severity) VALUES ('-1', '-1', '-1', '$cookie', '$user', '$algo', '$choice');";
$query_handle = $connect->prepare($query) or print "<b>MySQL: Query Preparation failed.</b>";
$query_handle->execute() or print "<b>MySQL: Query Execution failed.</b>";